package com.luobu.javaee.configuration;
import com.luobu.javaee.util.FileIO;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;
import java.io.IOException;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        String url = FileIO.getResourceDir() + File.separator + "picture";
        // 添加资源处理器，将请求映射到资源目录
        registry.addResourceHandler("picture")
                .addResourceLocations(url);
    }
}

